webfile:
	cd Web; scp web.xml clic:resin-3.1.12/webapps/ROOT/WEB-INF/; \
	cd classes; scp *.java clic:resin-3.1.12/webapps/ROOT/WEB-INF/classes

all: data webfile

data: teams gamelogs people rosters plays
	mkdir -p output
	cp Scripts/*.sql output/
	#tar -pczf data.tar.gz output
	#scp data.tar.gz clic:.
	#ssh clic "tar xzf data.tar.gz"

teams: RSParser.jar
	mkdir -p output
	java -jar RSParser.jar -t Data/teams.txt
	mv Data/teams.sql output

plays: RSParser.jar
	mkdir -p output/plays
	cd Data/events; java -jar ../../RSParser.jar -l *.EVA *.EVN
	mv Data/events/*.sql output/plays
	mv output/plays/batters.sql output/
	mv output/plays/pitchers.sql output/
	cd output; \
	ls -d plays/* | sed -e 's/plays/@plays/' | sed -e 's/.sql//' > plays.sql
	
rosters: RSParser.jar
	mkdir -p output/rosters
	cd Data/events; java -jar ../../RSParser.jar -r *.ROS
	mv Data/events/*.sql output/rosters
	cd output; \
	ls -d rosters/* | sed -e 's/rosters/@rosters/' | sed -e 's/.sql//' > rosters.sql
	
people: RSParser.jar
	java -jar RSParser.jar -p Data/people.txt
	mkdir -p output
	mv Data/people.sql output

gamelogs: RSParser.jar
	java -jar RSParser.jar -g 1 Data/gamelogs/gl20*.txt
	java -jar RSParser.jar -g 2 Data/gamelogs/gldv.txt
	java -jar RSParser.jar -g 3 Data/gamelogs/gllc.txt
	java -jar RSParser.jar -g 4 Data/gamelogs/glws.txt
	
	mkdir -p output/gamelogs
	mv Data/gamelogs/*.sql output/gamelogs
	cd output; \
	ls -d gamelogs/* | sed -e 's/gamelogs/@gamelogs/' | sed -e 's/.sql//' > games.sql
	
RSParser.jar: RSParser/src/*.java
	cd RSParser/src; make
	
.PHONY : clean
clean:
	cd RSParser/src; make clean
	rm -rf output data.tar.gz
